package co.fitstart.signin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.course.round.CourseRoundResult;
import co.fitstart.entity.course.schedule.CourseSchedule;
import co.fitstart.entity.course.schedule.ScheduleStatus;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Dao("hibernate")
public interface CourseRoundDao {

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM CourseRoundResult WHERE courseRound = :courseRound")
    public CourseRoundResult loadCourseRoundResult(@Variable("courseRound") CourseRound courseRound);

    /**
     * 
     * @param courseRound
     * @param scheduleStatus
     * @return
     */
    @Query("FROM CourseSchedule WHERE disabled = false AND courseRound = :courseRound AND scheduleStatus = :scheduleStatus AND occurDate IS NOT NULL ORDER BY occurDate DESC")
    public List<CourseSchedule> listCourseSchedule(@Variable("courseRound") CourseRound courseRound, @Variable("scheduleStatus") ScheduleStatus scheduleStatus);
    
    /**
     * 
     * @param courseRound
     * @param scheduleStatus
     * @return
     */
    @Query("SELECT COUNT(*) FROM CourseSchedule WHERE disabled = false AND courseRound = :courseRound AND scheduleStatus = :scheduleStatus")
    public int count(@Variable("courseRound") CourseRound courseRound, @Variable("scheduleStatus") ScheduleStatus scheduleStatus);

    
}
